package com.wan.rabbitmq.controller;


import com.wan.rabbitmq.mq.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 万明宇 on 2018/3/5.
 */
@RestController
@RequestMapping("/rabbit")
public class RabbitController {

    @Autowired
    private UserSender userSender;

    @Autowired
    private HelloSender helloSender;

    @Autowired
    private HelloSender1 helloSender1;

    @Autowired
    private HelloSender2 helloSender2;

    @Autowired
    private TopicSender topicSender;

    @Autowired
    private FanoutSender fanoutSender;

    @Autowired
    private TopicSenderTest01 topicSenderTest01;

    @Autowired
    private TopicSenderTest02 topicSenderTest02;

    @GetMapping("helloQueue")
    public void helloQueue(){
        for (int i = 0; i < 10; i++) {
            helloSender1.send("hellomsg:" + i);
            helloSender2.send("hellomsg:" + i);
        }
    }
    /**
     * 实体类传输测试
     */
    @GetMapping("/userTest")
    public void userTest() {
        userSender.send();
    }

    @GetMapping("topicTest")
    public void topicTest(){
        topicSender.send();
    }

    /**
     * fanout exchange类型rabbitmq测试
     */
    @GetMapping("/fanoutTest")
    public void fanoutTest() {
        fanoutSender.send();
    }


    @GetMapping("/myTopic01")
    public void myTopic01(){
        topicSenderTest01.send();
        topicSenderTest02.send();
    }
}
